﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using MVVM_CAD.Common;
using MVVM_CAD.Strategy;
using MVVM_CAD.ViewModel;
using Ninject;

namespace WPF_CAD.Test.ViewModel
{
    [TestClass]
    public class ToolsViewModelFixture
    {
        private ToolsViewModel _viewModel;
        private IKernel _kernel;
        [TestInitialize]
        public void SetUp()
        {
            //Arrange
            var mock = new Mock<IStrategy>();
            _kernel = new StandardKernel(new ViewModelsModule());
            _viewModel = _kernel.Get<ToolsViewModel>();
        }

        [TestMethod]
        public void ChangeStategyByCommandToLineToolStrategy()
        {
            //Arrange
            var actualstrategy = _viewModel.Strategy;
            //Act
            _viewModel.LineToolCommand.Execute(null);
            //Assert
            Assert.AreNotSame(actualstrategy, _viewModel.Strategy);
            Assert.IsInstanceOfType(_viewModel.Strategy, typeof(LineToolStrategy));
        }

        [TestMethod]
        public void ChangeStrategyByCommandToPointStrategy()
        {
            //Arrange
            var actualstrategy = _viewModel.Strategy;
            //Act
            _viewModel.PointToolCommand.Execute(null);
            //Assert
            Assert.AreNotSame(actualstrategy, _viewModel.Strategy);
            Assert.IsInstanceOfType(_viewModel.Strategy, typeof(PointToolStrategy));
        }

        [TestMethod]
        public void ChangeStrategyByCommandToPolyLineStrategy()
        {
            //Arrange
            var actualstrategy = _viewModel.Strategy;
            //Act
            _viewModel.PolyLineToolCommand.Execute(null);
            //Assert
            Assert.AreNotSame(actualstrategy, _viewModel.Strategy);
            Assert.IsInstanceOfType(_viewModel.Strategy, typeof(PolyLineToolStrategy));
        }

        [TestMethod]
        public void ChangeStrategyByCommandToCircleStrategy()
        {
            //Arrange
            var actualstrategy = _viewModel.Strategy;
            //Act
            _viewModel.CircleToolCommand.Execute(null);
            //Assert
            Assert.IsNotNull(_viewModel.Strategy);
            Assert.AreNotEqual(actualstrategy, _viewModel.Strategy);
            Assert.IsInstanceOfType(_viewModel.Strategy, typeof(CircleToolStrategy));
        }

        [TestMethod]
        public void ChangeStrategyByCommandToSplineStrategy()
        {
            //Arrange
            var actualstrategy = _viewModel.Strategy;
            //Act
            _viewModel.SplineToolCommand.Execute(null);
            //Assert
            Assert.IsNotNull(_viewModel.Strategy);
            Assert.AreNotEqual(actualstrategy, _viewModel.Strategy);
            Assert.IsInstanceOfType(_viewModel.Strategy, typeof(SplineToolStrategy));
        }

        [TestMethod]
        public void ChangeStrategyByCommandToSelectionStrategy()
        {
            //Arrange
            var actualstrategy = _viewModel.Strategy;
            //Act
            _viewModel.ArcToolCommand.Execute(null);
            //Assert
            Assert.IsNotNull(_viewModel.Strategy);
            Assert.AreNotSame(actualstrategy, _viewModel.Strategy);
            Assert.IsInstanceOfType(_viewModel.Strategy, typeof(ArcToolStrategy));

        }

        [TestMethod]
        public void ChangeStrategyByCommandToArcStrategy()
        {
            //Arrange
            var actualstrategy = _viewModel.Strategy;
            //Act
            _viewModel.ArcToolCommand.Execute(null);
            //Assert
            Assert.AreNotSame(actualstrategy, _viewModel.Strategy);
            Assert.IsInstanceOfType(_viewModel.Strategy, typeof(ArcToolStrategy));

        }

        [TestMethod]
        public void ChangeStrategyByCommandToDeleteStrategy()
        {
            //Arrange
            var actualstrategy = _viewModel.Strategy;
            //Act
            _viewModel.DeleteToolCommand.Execute(null);
            //Assert
            Assert.AreNotSame(actualstrategy, _viewModel.Strategy);
            Assert.IsInstanceOfType(_viewModel.Strategy, typeof(DeleteToolStrategy));

        }

    }
}
